import { methods, request } from '@/utils/request'; //设置自己的request路径

const actions = {
  getactivityList: {
    //获取活动列表
    name: 'getactivityList',
    url: '/api/activity/all',
  },
  getcurTimeActivities: {
    //获取当前时间之后的活动
    name: 'getcurTimeActivities',
    url: '/api/activity/getSubsequentActivity?stuCode='
  },
  getReportAndActivity: {
    //工作台获取通知与活动
    name: 'getReportAndActivity',
    url: '/api/activity/getAllActivity?stuCode='
  },
  getOwnActivityList: {
    //获取我的活动列表
    name: 'getOwnActivityList',
    url: '/api/activity/studentall'
  },
  // putusrRepotInfo: {
  //   //设置用户到站信息
  //   name: 'putusrRepotInfo',
  //   url: '/api/stuinfo/setreport'
  // },
  // getusrFamilyInfo: {
  //   //获取用户家庭信息
  //   name: 'getusrFamilyInfo',
  //   url: '/api/stuinfo/getfamily'
  // },
  // putusrFamilyInfo: {
  //   //设置用户家庭信息
  //   name: 'putusrFamilyInfo',
  //   url: '/api/stuinfo/setfamily'
  // },
  // getusrTuitionInfo: {
  //   //获取用户学费信息
  //   name: 'getusrTuitionInfo',
  //   url: '/api/stuinfo/getpayment'
  // },
  // putusrTuitionInfo: {
  //   //设置用户学费信息
  //   name: 'putusrTuitionInfo',
  //   url: '/api/stuinfo/setpayment'
  // },
};

const customRequest = (action: any, token: any, formdata: any = null) => {
  const options: any = {
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      Accept: 'application/json',
      Authorization: localStorage.getItem("token") ? localStorage.getItem("token") : '',
    }
  };
  let url = action.url;
  switch (action.name) {
    case actions.getactivityList.name://获取活动列表
      options['method'] = methods.get;
      break;
    case actions.getOwnActivityList.name://获取活动列表
      options['method'] = methods.get;
      break;
    case actions.getcurTimeActivities.name: //获取当前时间之后的活动
      options['method'] = methods.get;
      url += formdata;
      // console.log(url);
      break;
    case actions.getReportAndActivity.name: //获取当前时间之后的活动
      options['method'] = methods.get;
      url += formdata;
      // console.log(url);
      break;
    // case actions.putusrRepotInfo.name: //设置用户到站信息
    //   options['method'] = methods.put;
    //   options['body'] =JSON.stringify(formdata) ;
    //   // console.log(url);
    //   break;
    // case actions.getusrFamilyInfo.name: //获取用户家庭信息
    //   options['method'] = methods.get;
    //   // console.log(url);
    //   break;
    // case actions.putusrFamilyInfo.name: //设置用户到站信息
    //   options['method'] = methods.put;
    //   options['body'] =JSON.stringify(formdata) ;
    //   // console.log(url);
    //   break;
    // case actions.getusrTuitionInfo.name: //获取用户学费信息
    //   options['method'] = methods.get;
    //   // console.log(url);
    //   break;
    // case actions.putusrTuitionInfo.name: //    //设置用户学费信息
    //   options['method'] = methods.put;
    //   options['body'] =JSON.stringify(formdata) ;
    //   // console.log(url);
    //   break;
    default:
  }
  return request(url, options);
};

export function getactivityList(token: any, formdata: any) {//获取活动列表
  return customRequest(actions.getactivityList, token, formdata);
}
export function getOwnActivityList(token: any, formdata: any) {//获取活动列表
  return customRequest(actions.getOwnActivityList, token, formdata);
}
export function getcurTimeActivities(token: any, formdata: any) {///设置用户信息
  return customRequest(actions.getcurTimeActivities, token, formdata);
}
export function getReportAndActivity(token: any, formdata: any) {///设置用户信息
  return customRequest(actions.getReportAndActivity, token, formdata);
}
// export function getusrRepotInfo(token: any, formdata: any) {//获取用户到站信息
//   return customRequest(actions.getusrRepotInfo, token, formdata);
// }
// export function putusrRepotInfo(token: any, formdata: any) {///设置用户到站信息
//   return customRequest(actions.putusrRepotInfo, token, formdata);
// }
// export function getusrFamilyInfo(token: any, formdata: any) {//获取用户家庭信息
//   return customRequest(actions.getusrFamilyInfo, token, formdata);
// }
// export function putusrFamilyInfo(token: any, formdata: any) {///设置用户到站信息
//   return customRequest(actions.putusrFamilyInfo, token, formdata);
// }
// export function getusrTuitionInfo(token: any, formdata: any) {//获取用户家庭信息
//   return customRequest(actions.getusrTuitionInfo, token, formdata);
// }
// export function putusrTuitionInfo(token: any, formdata: any) {    //设置用户学费信息
//   return customRequest(actions.putusrTuitionInfo, token, formdata);
// }
